
import jmath from "@/_js/math";
import jfy from "@/_js/fy"; 

const weexHttp = weex.requireModule("WeexHttp");
export default {
  /**
   * https post请求 加密 
   * @param {String} url 访问链接
   * @param {JSON} params 参数
   * @param {Boolean} isToken turn 需要登陆
   * @param {Function} callback 结果回到
   * @param {Number} time 超时时间
   */
  postX(url, params, isToken, callback, time = 0) {

  
    if(typeof params == "object"){params = JSON.stringify(params)}
    weexHttp.postX(url, params, isToken, (data)=>{

      data = jmath.gfData(data);
      jfy.fy(data, (data)=>{
        callback(data);
      });
    }, time);
  },

  post(url, params, isToken, callback, time = 0) {
    if(typeof params == "object"){params = JSON.stringify(params)}
    weexHttp.post(url, params, isToken, (data)=>{
      data = jmath.gfData(data);
      
      jfy.fy(data, (data)=>{
        callback(data);
      });
    }, time);
  },

  postGa(url, params, isToken, callback, time = 0) {
    if(typeof params == "object"){params = JSON.stringify(params)}
    weexHttp.postGa(url, params, isToken, (data)=>{
      data = jmath.gfData(data);
      callback(data);
    }, time);
  },
}